//
//  ControllerManager.m
//  拖小延闹钟
//
//  Created by rimi on 15/10/8.
//  Copyright (c) 2015年 Liukai. All rights reserved.
//

#import "ControllerManager.h"

@interface ControllerManager ()
@property (nonatomic, strong) LeftViewController *leftViewController;
@end
@implementation ControllerManager

//单例
+(ControllerManager *)shareControllerManager {
    static ControllerManager *manager;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[ControllerManager alloc] init];
    });
    return manager;
}

#pragma mark -- Getter
- (UINavigationController *)rootViewController {
    if (!_rootViewController) {
        _rootViewController = ({
            UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.drawViewController];
            nav.navigationBarHidden = YES;
            nav;
        });
    }
    return _rootViewController;
}

- (DrawerViewController *)drawViewController {
    if (!_drawViewController) {
        _drawViewController = ({
            DrawerViewController *drawVC = [[DrawerViewController alloc] initWithMainViewController:self.mainViewController LeftViewController:self.leftViewController];
            drawVC;
        });
    }
    return _drawViewController;
}

- (MainViewController *)mainViewController {
        if (!_mainViewController) {
    NSArray *classNameArray = @[@"DelayViewController",@"GetUpManagerViewController",@"CommunityViewController"];
    NSMutableArray *viewControllers = [NSMutableArray arrayWithCapacity:3];
    [classNameArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        Class class = NSClassFromString(obj);
        UIViewController *viewController = [[class alloc] init];
        [viewControllers addObject:viewController];
    }];
    _mainViewController = ({
        MainViewController *mainVC = [[MainViewController alloc] initWithViewControllers:viewControllers pictureArrray:nil];
        mainVC;
    });
    }
    return _mainViewController;
}

- (LeftViewController *)leftViewController {
    if (!_leftViewController) {
        _leftViewController = ({
            LeftViewController *leftVC = [[LeftViewController alloc] init];
            leftVC;
        });
    }
    return _leftViewController;
}







@end
